//
//  CZCategoryViewController.m
//  QQ空间
//
//  Created by zhangping on 16/2/3.
//  Copyright © 2016年 zhangping. All rights reserved.
//

#import "CZCategoryViewController.h"
#import "CZDropdownMainCell.h"
#import "CZDropdownSubCell.h"
#import "CZCategoryViewModel.h"

static NSString *const mainCellIdentifier = @"mainCell";
static NSString *const subCellIdentifier = @"subCell";

@interface CZCategoryViewController () <UITableViewDataSource, UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *mainTableView;

@property (weak, nonatomic) IBOutlet UITableView *subTableView;

@property (nonatomic, strong) CZCategoryViewModel *categoryVM;
@end

@implementation CZCategoryViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.preferredContentSize = CGSizeMake(400, 400);
    
    [self.mainTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:mainCellIdentifier];
    
    [self.subTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:subCellIdentifier];
    
    // TODO: 测试加载数据
    
    CZLog(@"加载的模型数据: %@", self.categoryVM.categories);
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 20;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (tableView == self.mainTableView) {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:mainCellIdentifier forIndexPath:indexPath];
        
        cell.textLabel.text = @"main";
        
        return cell;
    } else {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:subCellIdentifier forIndexPath:indexPath];
        
        cell.textLabel.text = @"sub";
        
        return cell;
    }
}

#pragma mark - 懒加载
- (CZCategoryViewModel *)categoryVM {
    if (_categoryVM == nil) {
        _categoryVM = [[CZCategoryViewModel alloc] init];
    }
    
    return _categoryVM;
}
@end
